package com.adou.d11;

public class RegexTest {
    public static void main(String[] args) {
        System.out.println(checkQQ(null));
        System.out.println(checkQQ("123456"));
        System.out.println(checkQQ("123q56"));

        System.out.println("//////////////////////////-");
        System.out.println(checkQQ1(null));
        System.out.println(checkQQ1("123456"));
        System.out.println(checkQQ1("123q56"));
    }

    public static boolean checkQQ1(String qq) {
        return qq != null && qq.matches("[1,9]\\d{5,9}");
    }

        public static boolean checkQQ(String qq){
        // 是否为null
        if(qq == null || qq.startsWith("0") || qq.length() < 6 || qq.length() > 20) {
            return false;
        }

        // 判断qq是否数字组成
        for (int i = 0; i < qq.length(); i++) {
            char ch = qq.charAt(i);
            if(ch < '0' || ch > '9') {
                return  false;
            }
        }
        return true;

    }
}
